package com.haoshuang.zhouzhoubang.ui.adapter


import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemFw11Binding
import com.haoshuang.zhouzhoubang.model.bean.X
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.load
import java.math.BigDecimal


class Fw11Adapter(data: MutableList<X>) :
    BaseBindingQuickAdapter<X, ItemFw11Binding>(data){

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: X?) {
        if (item == null) return
        val binding = ItemFw11Binding.bind(holder.itemView)
        val price = BigDecimal.valueOf(item.rate * item.price)
        val unit = if (item.is_attr == 1) "起" else ""
        binding.apply {
            ivImage.load(item.image, R.mipmap.default_image)
            tvName.text=item.cate_name
            tvExpectedEarnings.text = "预计赚${price.setScale(2, BigDecimal.ROUND_FLOOR)}元$unit"
        }
    }

}